package problems.solved;

public class Problem30 {
	private static final int TARGET = 1000000;//Integer.MAX_VALUE;
	private static final int POWER = 5;
	
	public static void main(String[] args) {
		int sum = 0;
		for (int i = 11; i < TARGET; i++) {
			if (isSumOfPowers(i)) {
				sum += i;
				System.out.println(i);
			}
		}
		System.out.println(sum); // 443839
	}

	private static boolean isSumOfPowers(int i) {
		int sum = 0;
		for (char c : String.valueOf(i).toCharArray()) {
			sum += Math.pow(c-48, POWER);
		}
		return sum == i;
	}
}
